﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Commonlib;
namespace DAL
{
    public class ClothDAL
    {
        /// <summary>
        /// 根据限制条件获取布料视图中的数据
        /// </summary>
        public DataTable getClothView(string limit)
        {
            string cmdstr = "select * from ClothView where 1=1 and " + limit;
            return SqlHelper.ExecuteDataSet(SqlHelper.SqlConnectionString, CommandType.Text, cmdstr, null).Tables[0];
        }

        public void addCloth(Albon.Model.Cloth cloth)
        {
            SqlParameter[] parameters =new SqlParameter[] {
					new SqlParameter("@ID", cloth.ID),
					new SqlParameter("@companyID", cloth.companyID),
					new SqlParameter("@clothNo", cloth.clothNo),
					new SqlParameter("@widthID", cloth.widthID),
					new SqlParameter("@clothPrice",cloth.clothPrice),
					new SqlParameter("@unitID", cloth.unitID),
					new SqlParameter("@clothColor",cloth.clothColor),
					new SqlParameter("@clothQuality", cloth.clothQuality),
					new SqlParameter("@imgUrl", "No Image"),
					new SqlParameter("@active", true),
					new SqlParameter("@remark", cloth.remark)
            };
            SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnectionString, CommandType.StoredProcedure, "p_clothadd", parameters);
        }
    }
}
